/****************************************
*  This file created using "Writer B"   *
*      a program written by CTonk       *
*          ctonk87@hotmail.com          *
*     [timestamp 02/20/06  12:51:00]    *
****************************************/

// Exit.cpp

#ifndef CPP_EXIT
#define CPP_EXIT

#include "definitions.h"
#include <fstream>
#include "exit.h"

int Exit::numExits = 0;

// Constructors...
Exit::Exit() {
	_there = false;
	_point = 0;
	_door = false;
	_open = true;
	_lock = false;
	_locked = false;
	_key = 0;
	_flags = 0;
	numExits++;
}

Exit::Exit( Exit& it ) {
	_there = it.GetThere();
	_point = it.GetPoint();
	_door = it.GetDoor();
	_open = it.GetOpen();
	_lock = it.GetLock();
	_locked = it.GetLocked();
	_key = it.GetKey();
	_flags = it.getFlags();
	numExits++;
}

Exit::~Exit() {
	numExits--;
}

// Operators...
Exit& Exit::operator = ( Exit& it ) {
	_there = it.GetThere();
	_point = it.GetPoint();
	_door = it.GetDoor();
	_open = it.GetOpen();
	_lock = it.GetLock();
	_locked = it.GetLocked();
	_key = it.GetKey();
	_flags = it.getFlags();
	return *this;
}

// Public accessor methods...
bool Exit::GetThere() {
	return _there;
}

void Exit::SetThere( bool there ) {
	_there = there;
}

int Exit::GetPoint() {
	return _point;
}

void Exit::SetPoint( int point ) {
	_point = point;
}

bool Exit::GetDoor() {
	return _door;
}

void Exit::SetDoor( bool door ) {
	_door = door;
}

bool Exit::GetOpen() {
	return _open;
}

void Exit::SetOpen( bool open ) {
	_open = open;
}

bool Exit::GetLock() {
	return _lock;
}

void Exit::SetLock( bool lock ) {
	_lock = lock;
}

bool Exit::GetLocked() {
	return _locked;
}

void Exit::SetLocked( bool locked ) {
	_locked = locked;
}

int Exit::GetKey() {
	return _key;
}

void Exit::SetKey( int key ) {
	_key = key;
}

int Exit::getFlags() {
	return _flags;
}

void Exit::setFlags( int flags ) {
	_flags = flags;
}

// Other methods...
const char* Exit::StringName( int x ) {
	switch ( x ) {
		case 0: return "North";
		case 1: return "East";
		case 2: return "South";
		case 3: return "West";
		case 4: return "Up";
		case 5: return "Down";
		default: return "{Rerror{x";
	}
}

int Exit::Inverse( int given ) {
	// This function returns the inverse of the given direction.
	if ( given == NORTH)
		return SOUTH;
	else if ( given == EAST )
		return WEST;
	else if ( given == SOUTH )
		return NORTH;
	else if ( given == WEST )
		return EAST;
	else if ( given == UP )
		return DOWN;
	else if ( given == DOWN )
		return UP;
	else
		return -1;
}

void Exit::Save( std::ofstream& save ) {
	save << _there << ' ' << _point << ' ' << _door << ' '
		 << _open << ' ' << _lock << ' ' << _locked << ' '
		 << _key << ' ' << _flags << ' ';
	return;
}

void Exit::Load( std::ifstream& load ) {
	load >> _there >> _point >> _door >> _open >> _lock >> _locked >> _key >> _flags;
	return;
}



#endif // #ifndef CPP_EXIT
